< previous page page_143 next page >

Page 143
9f31265bb40b592b1929e18a47ab28e5.gif
   Me.Print avntEmployees(3, conSSN), _
           avntEmployees(3, conName), _
           avntEmployees(3, conSalary)
End Sub
In this example, a 4×3 array is created as a variant. Its created as a variant because you want to put string data and currency data into the same array. Whenever youre creating a multidimensional array, you should create constants for each column. Here, I created three constants to make the code more readable and to make it easier to remember which column I was putting data into. Any time you need to access a multidimensional array, you need to specify all the indexes to get to the particular element youre interested in.
User-defined Types
A user-defined type is a complex data type you create thats made of the built-in data types in Visual Basic. You can create a user-defined type to have many elements, where each element is a different data type. If youre familiar with the Pascal programming language, youll note that a user-defined type is very similar to a record. If youre familiar with C Language, youll note that its the same concept as a structure.
A user-defined type is used in Windows API calls (covered later in this book) and can be used to logically group your data into one variable. However, user-defined types have been replaced by the ability to create class modules. Lets still look at the syntax of user-defined types, because youll probably use them at one time or another for Windows API calls. Heres the basic syntax:
9f31265bb40b592b1929e18a47ab28e5.gif
[Private | Public] Type <TypeName>
    <ElementName> [(subscripts)] As DataType
    [<ElementName> [(subscripts)] As DataType]
. . .
End Type

 
< previous page page_143 next page >

If you like this book, buy it!